package com.lehecai.core.game;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.lehecai.core.IntegerBeanLabelItem;

/**
 * 服务器状态
 * @author He Wang
 */
public class ServerStatus extends IntegerBeanLabelItem {

	private static final long serialVersionUID = 7237155160478114896L;
	private static final Logger logger = LoggerFactory.getLogger(ServerStatus.class.getName());
	
	private static List<ServerStatus> items = new ArrayList<ServerStatus>();
	private static List<ServerStatus> queryItems = new ArrayList<ServerStatus>();
	
	protected ServerStatus(String name, int value) {
		this(name, value, false);
	}
	
	protected ServerStatus(String name, int value, boolean queryOnly) {
		super(ServerStatus.class.getName(), name, value);
		queryItems.add(this);
		
		if (!queryOnly) {
			items.add(this);
		}
	}
	
	public static ServerStatus getItem(int value){
		try {
			return (ServerStatus)ServerStatus.getResult(ServerStatus.class.getName(), value);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			return null;
		}
	}
	
	public static List<ServerStatus> getItems() {
		return items;
	}
	
	public static List<ServerStatus> getQueryItems() {
		return queryItems;
	}

	public static final ServerStatus ALL = new ServerStatus("全部", -1, true);
	public static final ServerStatus GAME_SERVER_STATUS_CLOSE = new ServerStatus("下线", 0);				
	public static final ServerStatus GAME_SERVER_STATUS_ON = new ServerStatus("在线", 1);
	public static final ServerStatus GAME_SERVER_STATUS_OFF = new ServerStatus("维护", 2);				
	public static final ServerStatus GAME_SERVER_STATUS_FUTURE = new ServerStatus("未开放", 3);
	public static final ServerStatus GAME_SERVER_STATUS_INVISIBLE = new ServerStatus("离线", 4);
}
